<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
	<meta charset="UTF-8">
	<title>往期活动详情页</title>
	<meta name="page-view-size" content="1280*720">
	<link rel="stylesheet" href="css/base.css">
	<link rel="stylesheet" href="css/B_detailActivety.css">
	<script type="text/javascript" src="lib/js/evm.js"></script>
	<script type="text/javascript" src="lib/js/Evm_djyw.js"></script>
	<script type="text/javascript" src="lib/js/key.js"></script>
	<script src="lib/js/md5.js" type="text/javascript" charset="utf-8"></script>
	<script src="lib/js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="lib/js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/api.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/public.js" type="text/javascript" charset="utf-8"></script>
	<style>
		.model:nth-child(4) {
			display: block;
			width: 100px;
			height: 35px;
			position: absolute;
			top: 450px;
			left: 170px;
			text-align: center;
			background: url(../images/like-1.png) no-repeat;
			background-position: top center;
			background-size: 60px 60px;
			padding-top: 80px;
			font-size: 15px;
			color: #fff;
		}
	</style>
</head>

<body>
	<div class="theoretical-bg" id="theoreticalMain">
		<div id="white-bg"></div>
		<div id="blue-bg"></div>
		<div class="model">
			<img class="imgs" src="" alt="">
			<!-- <div class="alearts">按确认键查看图集</div> -->
		</div>
		<div class="underImg">
			<div class="underimg">

				<div class="erweima">
					<img class="erweimas" src="images/erweima.png" alt="">
					<span>扫码分享</span>
				</div>
			</div>
		</div>
		<div class="status"><img class="status_img" src="" alt=""></div>
		<div class="info">
			<div class="title"></div>
		</div>
		<div class="item">
			<!-- <div class="baotime"></div> -->
			<div class="starttime"> <img src="/images/time.png"></div>
			<div class="organization"><img src="/images/team.png"></div>
			<div class="address"><img src="/images/address.png"></div>
			<div class="serviceTime"><img src="/images/time.png"></div>
			<div class="contacts"><img src="/images/person.png"></div>
			<div class="planpeople"><img src="/images/person.png"></div>
			<div class="completepeople"><img src="/images/person.png"></div>

			<!-- <div class="phone"><img src="/images/phone.png"></div> -->
			<!-- <div class="situation"></div> -->
			<!-- <div class="contacts"></div> -->
			<div>
				<div class="orange"><img src="/images/brief.png">活动简介</div>
			</div>
		</div>
		<div class="model">
			<div class="container" id="container">
				<div class="content" id="content">

				</div>
			</div>
		</div>
		<!-- <div class="bm_border">
			<div><img class="erweima" src="" alt=""></div>
			<div>微信扫码报名</div>
		</div> -->
		<div class="plan">
			<div class="planRecruit">
				<span>计划招募</span>
				<span class="plannum"></span>
			</div>
		</div>
		<div class="complete">
			<div class="planRecruit">
				<span>已招募数</span>
				<span class="completenum"></span>
			</div>
		</div>

		<div class="model" id="likes">
			<img src="images/like-1.png" alt="">
			<p>100</p>
		</div>

		<div class="model joinborder" id="joinborder">
			<span class="joinning">我要报名</span>
		</div>

	</div>
</body>
<script>
	var modelIndex = {
		disUser: true,
		specialState: 'didi',
		index: 2, //初始位置
		listName: 'model', //模块名称
		containerId: 'theoreticalMain', //包含模块的标签id
		thisContain: 'container', //翻滚外容器
		thisDetail: 'content', //翻滚内容
	}
	var articleRun;

	function getMessage() {
		var param = {
			id: TV.GetParam('id'),
			area_id: $.cookie('TV_CST_AREA'),
			// access_token: $.cookie("TV_CST_TOKEN"),

		}
		GetDatas('getActivity', param, function (err, res) {
			mess = res.data;
			console.log(mess, 'likes')
			$('.title').html(mess.title);

			$('.endtime').append(" <div class=orange>结束时间&nbsp;:</div>&nbsp; " + mess.format_end_time);
			$('.starttime').append(" <div class=orange>活动时间&nbsp;:</div> &nbsp;" + mess.format_start_time + ' 至 ' +
				mess
				.format_end_time);
			if (mess.group_name == '') {
				$('.organization').append('<div class=orange>发起组织&nbsp;:</div>&nbsp;' + "暂无")
			} else {
				$('.organization').append('<div class=orange>发起组织&nbsp;:</div> &nbsp;' + mess.group_name)
			}

			$('.address').append('<div class=orange>活动地点&nbsp;:</div>&nbsp;' + mess.address);
			if (mess.service_time != null) {
				$('.serviceTime').append('<div class=orange>服务时长&nbsp;:</div>&nbsp;' + mess.service_time + "小时");
			} else {
				$('.serviceTime').append('<div class=orange>服务时长&nbsp;:</div>&nbsp;暂无');
			}

			// $('.phone').append('<div class=orange>联系电话</div>：' + mess.phone);
			$('.contacts').append('<div class=orange>联&nbsp;&nbsp;系&nbsp;&nbsp;人&nbsp;:</div>&nbsp;' + mess
				.contacter + '&nbsp;&nbsp;' + mess.phone);
			$('.planpeople').append('<div class=orange>计划招募&nbsp;&nbsp;:</div>&nbsp;' + (mess
				.person_limit || "不限"));
			$('.completepeople').append('<div class=orange>已招募数&nbsp;&nbsp;:</div>&nbsp;' + (mess
				.joincount || "不限"));

			$("#likes p").html(mess.likes)

			$('.content').append(mess.content);
			$('.plannum').html(mess.person_limit || "不限");
			$('.completenum').html(mess.joiner.length || "0");
			$('.status_img').attr("src", "images/rowstatus" + mess.status + ".png");

			if (mess.status == 2) {
				$('.joinning').html("活动已结束");
				$('.model:last-child').css("background", "gray");

			}
			if (mess.status == 0 ||mess.status == 1) {
				$('.erweima >span').html("扫码报名");
			}
			$('.imgs').attr('src', mess.images ? API_URL.imgURL + mess.images : "/images/nonePic.png");
			// $('.').html(mess.);
			var surl = API_URL.loginURL + "home/index/qrcode?url=" + encodeURIComponent(
				API_URL.activityUrl + '/' + TV.GetParam('id'))
			$('.erweimas').attr('src', surl)
		})
		// right.toggleFocus();
	}

	getMessage();

	function direOpt(index, directive) {
		if (index == 1) { //文章翻滚
			TV.articleMove(directive, modelIndex.thisContain, modelIndex.thisDetail);
		}
		if (directive == "up") { //上
			if (index == 3) {
				index = 2
			}
			console.log('toptop')


		} else if (directive == "down") { //下
			if (index == 1) { //文章翻滚
				TV.articleMove(directive, modelIndex.thisContain, modelIndex.thisDetail);
			}
			console.log('downdown', index)
			if (mess.status == "2") {

			} else {
				if (index == 2) {
					index = 3
				}
			}


		} else if (directive == "backwards") { //左
			if (index == 1) {
				index = 2
				clearInterval(articleRun)
			}

		} else if (directive == "forwards") {
			if (index == 2) {
				index = 1
			}

		}
		return index;
	}

	function direEnter(index) {
		console.log(index)
		if (index == 0) {
			// window.location.href = './carrousel.html?id=' + TV.GetParam('id') + '&type=activety';
		} else if (index == 1) { //点单预约
			var params = {
				id: TV.GetParam('id'),
				name: EVM.cookie.getValue('TV_CST_NAME'),
				mobile: EVM.cookie.getValue('TV_CST_MOBILE'),
				access_token: $.cookie('TV_CST_TOKEN'),
			}
			if (mess.status == 2) {
				GetDatas('like', params, function (err, res) {
					resOpt.call(this, res)
				});
			} else {
				if (mess.is_bm == "99") {
					GetDatas('getReservation', params, function (err, res) {
						resOpt.call(this, res)
					});
				} else {
					GetDatas('like', params, function (err, res) {
						resOpt.call(this, res)
					});
				}

			}

		} else if (index == 2) {
			var params = {
				id: TV.GetParam('id'),
				name: EVM.cookie.getValue('TV_CST_NAME'),
				mobile: EVM.cookie.getValue('TV_CST_MOBILE'),
				access_token: $.cookie('TV_CST_TOKEN'),
			}
			// if (mess.status == 1) {
			GetDatas('like', params, function (err, res) {
				resOpt.call(this, res)
			});
			// }
		} else if (index == 3) {
			var params = {
				id: TV.GetParam('id'),
				access_token: $.cookie('TV_CST_TOKEN'),
			}
			// if (mess.status == 1) {
			GetDatas('activityJoin', params, function (err, res) {
				if (res.code == 0) {
					TV.PromptMsg("报名成功");

				} else if (res.code == 10105) {
					TV.PromptMsg("您不是志愿者，请前往手机端加入志愿者");
					// setTimeout(function(){
					// 	window.location.href = './joinvolunteer.html'
					// },2000)
				} else if (res.code == 401) {
					TV.PromptMsg(res.message);
					setTimeout(function () {
						window.location.href = './login.html'
					}, 2000)
				} else {
					TV.PromptMsg(res.message);

				}
			});



		}

	}

	function resOpt(res) {
		if (res.code == 0) {
			TV.PromptMsg("点赞成功");
			$("#likes p").html(res.data.likes)

		} else if (res.code == 10002) {
			TV.userLogin();
			direEnter(index);
		} else if (res.code == 401) {
			TV.PromptMsg(res.message);
			setTimeout(function () {
				window.location.href = './login.html'
			}, 2000)
		} else {
			TV.PromptMsg(res.message)
		}
	}
</script>
<script type="text/javascript" src="js/index.js"></script>

</html>